//
//  ViewController.m
//  MacWeb
//
//  Created by hebidu on 16/3/14.
//  Copyright © 2016年 Boye. All rights reserved.
//

#import "ViewController.h"
#import <WebKit/WebKit.h>
#import "NSString+enCodeUrl.h"
@interface ViewController()

@property (weak) IBOutlet WebView *mainWebView;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self show];
    
    
}
- (void)setRepresentedObject:(id)representedObject {
    [super setRepresentedObject:representedObject];
}

//加载页面
- (void)show{
    if ([self.type isEqualToString:@"login"]) {
        NSString *urlStr = [NSString stringWithFormat:@"%@?username=%@&password=%@&date=20160101&bookid=2",CommonLoginSuccessPath,self.userName,self.password];
        [self request:urlStr];
        NSLog(@"%@",urlStr);
    }else if ([self.type isEqualToString:@"quick0"]){
        NSString *urlStr = [NSString stringWithFormat:@"%@?number=%@&bookId=0&date=20160101",QuickLoginSuccessPath,self.userName];
        NSLog(@"%@",urlStr);
        NSURL *url = [NSURL URLWithString:urlStr];
        NSURLRequest *  request = [[NSURLRequest alloc]initWithURL:url];
        [self.mainWebView.mainFrame loadRequest:request];
    }else if ([self.type isEqualToString:@"多用户"]){
        NSString *urlStr = [NSString stringWithFormat:@"%@?number=%@&bookId=1&date=20160101&userId=%@",MoreUserLoginPath,self.userName,self.userID];
        NSLog(@"--------------%@-------------------",urlStr);
    
        [self request:urlStr];
    }else if ([self.type isEqualToString:@"forget"]){
        NSString *url = ForgrtPwdPath;
        [self request:url];
    
    }
}

- (void) request:(NSString *)completePath{
    NSString *requestStr = [NSString URLEncodedString:completePath];
    NSURL* url = [[NSURL alloc] initWithString:requestStr];
    NSURLRequest *  request = [[NSURLRequest alloc]initWithURL:url];
    [self.mainWebView.mainFrame loadRequest:request];
}

@end
